package com.alibaba.citrus.cr.platform.enhance.functions.dimension.entity;

import com.alibaba.citrus.cr.common.util.SpringContextUtil;
import com.alibaba.citrus.cr.platform.enhance.repository.DimensionWriteRepository;

import com.epoch.app.crplatformenhance.sdo.DimensionSDO;
import lombok.Getter;

@Getter
public class DimensionEntity {

    private DimensionSDO dimensionSDO;

    private static DimensionWriteRepository dimensionWriteRepository;

    static{
        dimensionWriteRepository = SpringContextUtil.getBean(DimensionWriteRepository.class);
    }

    public static DimensionEntity of(DimensionSDO dimensionSDO){
        DimensionEntity dimension = new DimensionEntity();
        dimension.dimensionSDO = dimensionSDO;
        return dimension;
    }


    public String update() {
        String id = dimensionWriteRepository.update(this.dimensionSDO);
        return id;
    }

    public String delete() {
        String id = dimensionWriteRepository.delete(dimensionSDO);
        return id;
    }

    public void updatePriority() {
        dimensionWriteRepository.modify(dimensionSDO);
    }

    public void deleteByPriority() {
        dimensionWriteRepository.deleteByPriority(dimensionSDO);
    }
}
